import scrapy
from youku_rebot.youku_rebot.items import YoukuRebotItem


class spider(scrapy.Spider):
    name = "youku"
    allowed_youku = ["youku.com"]
    start_urls = [
        "https://v.youku.com/v_show/id_XNDI1MDc1NTg0OA==.html?spm=a2h0j.11185381.listitem_page1.5!4~A&&s=efbfbd60efbfbd27efbf",
        "https://tv.youku.com/?spm=a2h0j.11185381.topNav.1~3~A"
    ]


def parse(self, response):
    for sel in response.xpath('//ul/li'):
        item = YoukuRebotItem()
        item['title'] = sel.xpath('a/text()').extract()
        item['link'] = sel.xpath('a/@href').extract()
        item['desc'] = sel.xpath('text()').extract()
        yield item
